package com.example.controller;


import com.example.base.response.Result;
import com.example.entity.Comment;
import com.example.entity.Params;
import com.example.service.CommentService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/comment")
@Api("评论信息管理")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/search")
    public Result findBySearch(Params params) {
        PageInfo<Comment> info = commentService.findBySearch(params);
        return Result.success(info);
    }

    @DeleteMapping("/{id}")

    public Result delete(@PathVariable Integer id) {
        commentService.delete(id);
        return Result.success();
    }

    @PostMapping("/insert")
    @ApiOperation("新增评论")

    public Result Insert(@RequestBody Comment comment) {

        commentService.addComment(comment);

        return Result.success();
    }


}
